using BBX.Common;
using BBX.Entity;
using BBX.Forum;

namespace BBX.Web
{
    public class userinfo : PageBase
    {
        public IUser user;
        public UserGroup group;
        public AdminGroup admininfo;
        public System.String[] score;
        public System.Boolean needlogin;
        public System.String score1;
        public System.String score2;
        public System.String score3;
        public System.String score4;
        public System.String score5;
        public System.String score6;
        public System.String score7;
        public System.String score8;
        public System.Int32 id = DNTRequest.GetInt("userid", -1);

        protected override void ShowPage()
        {
            pagetitle = "查看用户信息";
            if (!usergroupinfo.AllowViewpro && userid != id)
            {
                base.AddErrLine(string.Format("您当前的身份 \"{0}\" 没有查看用户资料的权限", usergroupinfo.GroupTitle));
                if (userid < 1)
                {
                    needlogin = true;
                }
                return;
            }
            if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("username")) && Utils.StrIsNullOrEmpty(DNTRequest.GetString("userid")))
            {
                base.AddErrLine("错误的URL链接");
                return;
            }
            if (id == -1)
            {
                id = Users.GetUserId(Utils.UrlDecode(DNTRequest.GetString("username")));
            }
            if (id == -1)
            {
                base.AddErrLine("该用户不存在");
                return;
            }
            user = Users.GetUserInfo(id);
            if (user == null)
            {
                base.AddErrLine("该用户不存在");
                return;
            }
            if (!user.ShowEmail && id != userid)
            {
                //this.user.Email = "";
                // 不影响脏数据，避免不小心被保存了
                user["Email"] = "";
            }
            score = Scoresets.GetValidScoreName();
            group = UserGroup.FindByID(user.GroupID);
            //this.admininfo = AdminUserGroups.AdminGetAdminGroupInfo(this.usergroupid);
            admininfo = AdminGroup.FindByID(usergroupid);
            score1 = ((System.Decimal)user.ExtCredits1).ToString();
            score2 = ((System.Decimal)user.ExtCredits2).ToString();
            score3 = ((System.Decimal)user.ExtCredits3).ToString();
            score4 = ((System.Decimal)user.ExtCredits4).ToString();
            score5 = ((System.Decimal)user.ExtCredits5).ToString();
            score6 = ((System.Decimal)user.ExtCredits6).ToString();
            score7 = ((System.Decimal)user.ExtCredits7).ToString();
            score8 = ((System.Decimal)user.ExtCredits8).ToString();
        }
    }
}